let fs = require('fs');
let path = require('path');
let json_path = path.resolve(__dirname,'aa.json');
let html_path = path.resolve(__dirname,'table.html');


fs.readFile(json_path,function(err,data){
	if(err) throw err;
	var jso = JSON.parse(data);


	var tableStr=jso.map(function(item){
		return `<tr>
<td>${item.name}</td>
<td>${item.age}</td>
<td>${item.sex}</td>
</tr>`;
		}).reduce(function(a,b){
	return a+b;
			});
	

	var str = `<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
	<table>${tableStr}</table>
</body>
</html>
		`;
	fs.writeFile(html_path,str,function(err2){
			if(err2) throw err2;
			console.log("写出完毕，你去看看吧");
		});
	});



